/*
  文章相关接口
*/
import $axios from '@/utils/request'
/**
 * @description: 获取文章频道
 * @param {*} 无
 * @return {*}
 */
export const channel = () => {
  return $axios({
    url: '/mp/v1_0/channels',
    method: 'GET'
  })
}

/**
 * @description: 获取文章列表
 * @param {*}
 * @return {*}
 */
export const articleList = data => {
  return $axios({
    url: '/mp/v1_0/articles',
    method: 'GET',
    params: data
  })
}

/**
 * @description: 删除文章
 * @param {*}
 * @return {*}
 */
export const removeContent = data => {
  return $axios({
    url: `/mp/v1_0/articles/${data}`,
    method: 'DELETE'
  })
}

/**
 * @description: 发表文章
 * @param {*}
 * @return {*}
 */
export const publishAnArticle = data => {
  return $axios({
    url: '/mp/v1_0/articles',
    method: 'POST',
    params: {
      draft: data.draft
    },
    data
  })
}

/**
 * @description: 获取文章
 * @param {*}
 * @return {*}
 */
export const getArticleId = data => {
  return $axios({
    url: `/mp/v1_0/articles/${data.id}`,
    method: 'GET'
  })
}

/**
 * @description: 修改文章
 * @param {*}
 * @return {*}
 */
export const edit = data => {
  return $axios({
    url: `/mp/v1_0/articles/${data.id}`,
    method: 'PUT',
    data
  })
}

/**
 * @description: 修改文章评论状态
 * @param {*}
 * @return {*}
 */
export const commentState = data => {
  return $axios({
    url: '/mp/v1_0/comments/status',
    method: 'PUT',
    params: {
      article_id: data.id
    },
    data
  })
}
